package cn.yuxiaoyuan.query;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class BaseQuery {
    private Integer page = 1;
    private Integer size = 10;
    //关键字查询
    private String keyword;

    public Integer getStart() {
        return (this.page - 1) * this.size;
    }

    public void setPage(Integer page) {
        if(page == null || page <= 1){
            this.page = 1;
        }else {
            this.page = page;
        }
    }

    public void setSize(Integer size) {
        if(size == null || size <= 0){
            this.size = 10;
        }else {
            this.size = size;
        }
    }
}
